class Documents::NewsController < Documents::BaseController

  def index
    @search = News.search(params[:search])  # TODO remove tabs, spaces...
    @news = @search.page(params[:page])
  end

  def show
    @comments = @news.document.comments
  end

  def new
    @news = News.new
  end

  def create
    @news = News.new(params[:news])
    @news.document.user = current_user

    if @news.save
      flash[:notice] = t('news.create.success')
      redirect_to :action => :index
    else
      render :action => :new
    end
  end

  def update
    if @news.update_attributes(params[:news])
      flash[:notice] = t('news.update.success')
      redirect_to :action => :index
    else
      render :action => :edit
    end
  end
end
